<!DOCTYPE html>
<html lang="en">
  <head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
  <meta content="" name="keywords">

  <title> Blog - </title>
  <meta name="description" content="" />
  <meta property="og:title" content="Blog" />
  <meta name="twitter:title" content="Blog" />
  <meta name="description" content="一个记录学习生活的场所. 大概会有五个方面内容: Thoughts: My thoughts and attitudes about learning everything in life. 思考：我对学习、生活中一切事物的想法和态度。 Critique: My comment, or about technology, or about life, or about something or a movie. 评论：我的评论，或关于技术，或关于生活、或关于某些事情或者一场电影。 Travel: My travel record, of course, may be a business trip haha. 旅行：我的旅行记录，当然可能是出差记录哈哈。 Moment: Some moments that I feel something and eager to write it down. Fragments in my life. Short memos. 片刻：有些时刻我觉得有些东西并且急于把它写下来. 我生命中的碎片 简短的备忘录。 Gallery: Pictures I&rsquo;d like to">
  <meta property="og:description" content="一个记录学习生活的场所. 大概会有五个方面内容: Thoughts: My thoughts and attitudes about learning everything in life. 思考：我对学习、生活中一切事物的想法和态度。 Critique: My comment, or about technology, or about life, or about something or a movie. 评论：我的评论，或关于技术，或关于生活、或关于某些事情或者一场电影。 Travel: My travel record, of course, may be a business trip haha. 旅行：我的旅行记录，当然可能是出差记录哈哈。 Moment: Some moments that I feel something and eager to write it down. Fragments in my life. Short memos. 片刻：有些时刻我觉得有些东西并且急于把它写下来. 我生命中的碎片 简短的备忘录。 Gallery: Pictures I&rsquo;d like to">
  <meta name="twitter:description" content="一个记录学习生活的场所. 大概会有五个方面内容: Thoughts: My thoughts and attitudes about learning everything in life. 思考：我对学习、生活中一切事物的想法和态度。 Critique: My comment, or about technology, or about life, or about something or a …">
  <meta name="author" content="{Description { .Site.Author.name }}"/>
  <meta name="twitter:card" content="summary" />
  <meta property="og:url" content="https://systemime.github.io/blog/" />
  <meta property="og:type" content="website" />
  <meta property="og:site_name" content="听风的小站" />

  <meta name="generator" content="Hugo 0.67.0" />
  <link rel="canonical" href="https://systemime.github.io/blog/" />
  <link rel="alternate" href="https://systemime.github.io/index.xml" type="application/rss+xml" title="听风的小站">
  <script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/jquery-1.12.4.min.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.7.1/katex.min.css" integrity="sha384-wITovz90syo1dJWVh32uuETPVEtGigN07tkttEqPv+uR2SE/mbQcG7ATL28aI9H0" crossorigin="anonymous">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  
  
  <link rel="stylesheet" href="https://systemime.github.io/css/main.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/my.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/pace.css" />
  <link rel="stylesheet" href="https://cdn.plyr.io/3.4.7/plyr.css">
  <link rel="stylesheet" href="https://systemime.github.io/css/lightgallery.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/baguetteBox.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/search.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/reward.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/share.min.css" />
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lora:400,700,400italic,700italic" />
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" />
  <link rel="stylesheet" href="https://systemime.github.io/css/pygment_highlights.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/highlight.min.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/toc.css" />
  <link rel="stylesheet" href="https://systemime.github.io/css/lightbox.css" />
  <link rel="stylesheet" href="https://systemime.github.io/live2d/css/live2d.css" />
  
  <link href="https://systemime.github.io/css/video-js.css" rel="stylesheet">


<meta name="baidu-site-verification" content="g8IYR9SNLF" />
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?cffe439e37449bb1c07ab26ab56484bb";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

<link rel="stylesheet" href="https://systemime.github.io/css/prism.css" />









<script src="https://systemime.github.io/js/pace.min.js" data-no-instant></script>



<script src="https://systemime.github.io/js/instantclick.min.js" data-no-instant></script>
   <script data-no-instant>
   InstantClick.on('change', function(isInitialLoad) {
     if (isInitialLoad === false) {
       if (typeof MathJax !== 'undefined') 
         MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
       if (typeof prettyPrint !== 'undefined') 
         prettyPrint();
       if (typeof _hmt !== 'undefined')  
         _hmt.push(['_trackPageview', location.pathname + location.search]);
       if (typeof ga !== 'undefined')  
           ga('send', 'pageview', location.pathname + location.search);
     }
   });
   InstantClick.init();
</script>




<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/gist-embed/2.7.1/gist-embed.min.js"></script>


<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
  (adsbygoogle = window.adsbygoogle || []).push({
    google_ad_client: "ca-pub-3925981084585036",
    enable_page_level_ads: true
  });
</script>



<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.1/photoswipe.min.css" integrity="sha256-sCl5PUOGMLfFYctzDW3MtRib0ctyUvI9Qsmq2wXOeBY=" crossorigin="anonymous" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/photoswipe/4.1.1/default-skin/default-skin.min.css" integrity="sha256-BFeI1V+Vh1Rk37wswuOYn5lsTcaU96hGaI7OUVCLjPc=" crossorigin="anonymous" />



<div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

<div class="pswp__bg"></div>

<div class="pswp__scroll-wrap">
    
    <div class="pswp__container">
      <div class="pswp__item"></div>
      <div class="pswp__item"></div>
      <div class="pswp__item"></div>
    </div>
    
    <div class="pswp__ui pswp__ui--hidden">
    <div class="pswp__top-bar">
      
      <div class="pswp__counter"></div>
      <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>
      <button class="pswp__button pswp__button--share" title="Share"></button>
      <button class="pswp__button pswp__button--fs" title="Toggle fullscreen"></button>
      <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>
      
      
      <div class="pswp__preloader">
        <div class="pswp__preloader__icn">
          <div class="pswp__preloader__cut">
            <div class="pswp__preloader__donut"></div>
          </div>
        </div>
      </div>
    </div>
    <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
      <div class="pswp__share-tooltip"></div>
    </div>
    <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
    </button>
    <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
    </button>
    <div class="pswp__caption">
      <div class="pswp__caption__center"></div>
    </div>
    </div>
    </div>
</div>

</head>

  <body>
    <nav class="navbar navbar-default navbar-fixed-top navbar-custom">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#main-navbar">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="https://systemime.github.io">听风的小站</a>
    </div>
    <div class="collapse navbar-collapse" id="main-navbar">
      <ul class="nav navbar-nav navbar-right">
        
          
            <li>
		    <a title="博客" href="https://systemime.github.io/blog/">博客</a>
              
              
            </li>
          
        
          
            <li>
		    <a title="片刻" href="https://systemime.github.io/moment/">片刻</a>
              
              
            </li>
          
        
          
            <li>
		    <a title="关于" href="https://systemime.github.io/about/">关于</a>
              
              
            </li>
          
        
          
            <li>
		    <a title="留言" href="https://systemime.github.io/message/">留言</a>
              
              
            </li>
          
        

        

        
        
      </ul>
    </div>

    <div class="avatar-container">
      <div class="avatar-img-border">
        
      </div>
    </div>

  </div>
</nav>






    
  <header class="header-section ">
    <div class="intro-header no-img">
      <div class="container">
        <div class="row">
          <div class="col-lg-12 col-md-12 col-md-offset-0">
            <div class="page-heading">
              <h1>Blog</h1>
              <hr class="small">
            </div>
          </div>
        </div>
      </div>
    </div>
  </header>

    
  <div class="container" role="main">
    <div class="row">
      <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
        
          <div class="well">
            <p>一个记录学习生活的场所. 大概会有五个方面内容:</p>
<hr>
<ul>
<li>Thoughts: My thoughts and attitudes about learning everything in life.<br>
<!-- raw HTML omitted -->思考：我对学习、生活中一切事物的想法和态度。<!-- raw HTML omitted --></li>
<li>Critique: My comment, or about technology, or about life, or about something or a movie.<br>
<!-- raw HTML omitted -->评论：我的评论，或关于技术，或关于生活、或关于某些事情或者一场电影。<!-- raw HTML omitted --></li>
<li>Travel: My travel record, of course, may be a business trip haha.<br>
<!-- raw HTML omitted -->旅行：我的旅行记录，当然可能是出差记录哈哈。<!-- raw HTML omitted --></li>
<li>Moment: Some moments that I feel something and eager to write it down. Fragments in my life. Short memos.
<!-- raw HTML omitted --><!-- raw HTML omitted -->片刻：有些时刻我觉得有些东西并且急于把它写下来. 我生命中的碎片 简短的备忘录。<!-- raw HTML omitted --></li>
<li>Gallery: Pictures I&rsquo;d like to share. My favourite ones.
<!-- raw HTML omitted --><!-- raw HTML omitted -->画廊：我想分享的图片. 我最喜欢的。<!-- raw HTML omitted --></li>
</ul>
<p>博客无序，随需随记</p>

          </div>
        
        <div class="posts-list">
          
            <article class="post-preview">
              <a href="https://systemime.github.io/blog/2019-09/%E4%BD%A0%E5%A5%BD/">
                <h2 class="post-title">你好</h2>

                
              </a>

              <p class="post-meta">
                Posted on September 20, 2019
              </p>
              <div class="post-entry">
                
                  <h1 id="你好啊">你好啊</h1>
<h4 id="陌生人">陌生人</h4>
<p>是梦，那就打碎它</p>

                
              </div>

              
                <span class="post-meta">
                  
                    #<a href="https://systemime.github.iotags/%E6%AC%A2%E8%BF%8E/">欢迎</a>&nbsp;
                  
                </span>
              

            </article>
          
            <article class="post-preview">
              <a href="https://systemime.github.io/blog/2019-09/linux%E5%88%9B%E5%BB%BA%E6%88%96%E5%88%A0%E9%99%A4swap%E5%88%86%E5%8C%BA/">
                <h2 class="post-title">Linux创建或删除swap分区</h2>

                
              </a>

              <p class="post-meta">
                Posted on September 20, 2019
              </p>
              <div class="post-entry">
                
                  <!-- raw HTML omitted -->
<h2 id="1-swap概述">1. swap概述</h2>
<!-- raw HTML omitted -->
<h2 id="2-检查是否有swap分区">2. 检查是否有swap分区</h2>
<p>命令如下：</p>
<pre><code>sudo swapon --show
</code></pre><p>如果没有任何输出，表示没有swap分区，也可以通过free命令验证一下</p>
<pre><code>free -h
</code></pre><pre><code>#Output
					total        used        free      shared  buff/cache   available
Mem:          486         316          81           5          88         132
Swap:         0             0             0  
</code></pre><p>可以看到Swap的大小是零，也就是没有swap分区。</p>
<h2 id="3-创建swap">3. 创建swap</h2>
<h4 id="31-创建swap分区">3.1 创建swap分区</h4>
<!-- raw HTML omitted -->
<!-- raw HTML omitted -->
<pre><code>dd if=/dev/zero of=/swapfile bs=1024 count=1024000
# 或
dd if=/dev/sda3  of=/swapfile bs=1M count=2048    【指定单位】
</code></pre><p><strong>参数详解</strong></p>
<ul>
<li>
<p>if  # 输入</p>
</li>
<li>
<p>of  # 输出</p>
</li>
<li>
<p>bs  # 块儿大小</p>
</li>
<li>
<p>count  # 总大小</p>
</li>
</ul>
<h4 id="32-创建linux交换文件">3.2 创建Linux交换文件</h4>
<pre><code>mkswap /swapfile  # 或【mkswap -f /swapfile】
</code></pre><h4 id="33-立即激活swapfile-交换文件">3.3 立即激活/swapfile 交换文件</h4>
<pre><code>swapon /swapfile
</code></pre><h4 id="34-查看是否生效">3.4 查看是否生效</h4>
<pre><code>［root@webserver ~］# sudo swapon --show

NAME      TYPE  SIZE USED PRIO
/swapfile file 1024M   0B   -1
</code></pre><p>通过以上输出信息可以看出，已经成功创建swap分区</p>
<h2 id="4-设置永久生效">4. 设置永久生效</h2>
<p>虽然现在已经生效，但是等下次服务器重启之后。该swap虚拟磁盘会失效，为保证永久生效，需要在<code>/etc/fstab</code>文件添加如下指令集：</p>
<pre><code>　　echo “/swapfile swap swap defaults 0 0” &gt;&gt; /etc/fstab
</code></pre><p>现在为止，swap分区已经完成创建。</p>
<h2 id="5-删除swap分区">5. 删除swap分区</h2>
<p>有时可能会需要删除swap分区，该如何正确进行删除分区哪？</p>
<h4 id="51-首先停止swap分区">5.1 首先停止swap分区</h4>
<pre><code>　　swapoff /swapfile
</code></pre><h4 id="52-删除swap分区文件">5.2 删除swap分区文件</h4>
<pre><code>　　rm -rf /swapfile
</code></pre><p>删除<code>/etc/swap</code>指定文件</p>
<p>这样就可以手工添加和删除swap分区。</p>
<p>代码如下：</p>
<pre><code>　　sed -i “/‘\/swapfile swap swap defaults 0 0’//” /etc/fstab
</code></pre><h2 id="6-优化swap设置">6. 优化swap设置</h2>
<h4 id="61-调整swappiness值">6.1 调整Swappiness值</h4>
<pre><code>sudo sysctl vm.swappiness=10
</code></pre><pre><code>#Output
vm.swappiness = 10
</code></pre><h4 id="62-调整cache-pressure值">6.2 调整Cache Pressure值</h4>
<pre><code>sudo sysctl vm.vfs_cache_pressure=50
</code></pre><pre><code>#Output
vm.vfs_cache_pressure = 50
</code></pre><h4 id="63-设置开机时自动调整这两项设置值">6.3 设置开机时自动调整这两项设置值</h4>
<p>在<code>/etc/sysctl.conf</code>文件最后添加下面两行内容</p>
<pre><code>vm.swappiness=10
vm.vfs_cache_pressure=50
</code></pre><p>OK，搞定，测试一下看pip是否能安装这个包了，哈哈，不再是Killed，变成了Successfully installed，没有问题，成功安装。</p>
<pre><code>#Output
Installing collected packages: pypinyin
Successfully installed pypinyin-0.33.0
</code></pre>
                
              </div>

              
                <span class="post-meta">
                  
                    #<a href="https://systemime.github.iotags/linux/">Linux</a>&nbsp;
                  
                    #<a href="https://systemime.github.iotags/swap/">swap</a>&nbsp;
                  
                </span>
              

            </article>
          
            <article class="post-preview">
              <a href="https://systemime.github.io/blog/2019-08/linux%E6%89%93%E5%BC%80-%E8%99%9A%E7%BA%BF%E6%96%87%E4%BB%B6%E5%90%8D/">
                <h2 class="post-title">Linux打开 “-” 虚线文件名</h2>

                
              </a>

              <p class="post-meta">
                Posted on August 22, 2019
              </p>
              <div class="post-entry">
                
                  <p>先注明原贴，在此处找到的解决方案:<br>
<a href="https://stackoverflow.com/questions/42187323/how-to-open-a-f-dashed-filename-using-terminal">How to open a f “-” dashed filename using terminal?</a></p>

                
              </div>

              
                <span class="post-meta">
                  
                    #<a href="https://systemime.github.iotags/linux/">Linux</a>&nbsp;
                  
                    #<a href="https://systemime.github.iotags/%E6%96%87%E4%BB%B6/">文件</a>&nbsp;
                  
                    #<a href="https://systemime.github.iotags/%E7%89%B9%E6%AE%8A%E7%AC%A6%E5%8F%B7/">特殊符号</a>&nbsp;
                  
                </span>
              

            </article>
          
            <article class="post-preview">
              <a href="https://systemime.github.io/blog/2019-08/lilinux-%E5%91%A8%E6%9C%9F%E5%AE%9A%E6%97%B6%E4%BB%BB%E5%8A%A1-crontab/">
                <h2 class="post-title">LiLinux 周期定时任务 Crontab</h2>

                
              </a>

              <p class="post-meta">
                Posted on August 20, 2019
              </p>
              <div class="post-entry">
                
                  <h2 id="一crontab简介">一、crontab简介</h2>
<h4 id="1-简介">1. 简介</h4>
<p>Linux crontab是用来定期执行程序的命令。</p>
<p>当安装完成操作系统之后，默认便会启动此任务调度命令。crond命令每分钟会定期检查是否有要执行的工作，如果有要执行的工作便会自动执行该工作。</p>
<p>而linux任务调度的工作主要分为以下两类：</p>
<ul>
<li>1、系统执行的工作：系统周期性所要执行的工作，如备份系统数据、清理缓存</li>
<li>2、个人执行的工作：某个用户定期要做的工作，例如每隔10分钟检查邮件服务器是否有新信，这些工作可由每个用户自行设置</li>
</ul>
<p>crontab命令用于设置周期性被执行的指令。</p>
<p>该命令从标准输入设备读取指令，并将其存放于 <strong>crontab</strong> 文件中，以供之后读取和执行</p>
<p>我们经常使用的是crontab命令是<code>cron table</code>的简写，它是cron的配置文件，也可以叫它作业列表，我们可以在以下文件夹内找到相关配置文件。</p>
<table>
<thead>
<tr>
<th>文件目录</th>
<th>作用</th>
</tr>
</thead>
<tbody>
<tr>
<td>/var/spool/cron/</td>
<td>每个用户包括root的crontab任务，每个任务以创建者的名字命名</td>
</tr>
<tr>
<td>/etc/crontab</td>
<td>负责调度各种管理和维护任务</td>
</tr>
<tr>
<td>/etc/cron.d/</td>
<td>存放任何要执行的crontab文件或脚本</td>
</tr>
<tr>
<td>/etc/cron.hourly、/etc/cron.daily、/etc/cron.weekly、/etc/cron.monthly</td>
<td>可以把脚本放在这些目录中，让它每小时/天/星期、月执行一次</td>
</tr>
</tbody>
</table>
<h4 id="2-确认服务状态">2. 确认服务状态</h4>
<pre><code># 终端里这个点应该事绿色的
[root@sys ~]# systemctl status crond.service
● crond.service - Command Scheduler
   Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; vendor preset: enabled)
   Active: active (running) since 二 2019-08-20 10:59:36 CST; 1min 6s ago
 Main PID: 1310 (crond)
   CGroup: /system.slice/crond.service
           └─1310 /usr/sbin/crond -n

8月 20 10:59:36 sys systemd[1]: Started Command Scheduler.
8月 20 10:59:36 sys systemd[1]: Starting Command Scheduler...
8月 20 10:59:36 sys crond[1310]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 11% if used.)
8月 20 10:59:37 sys crond[1310]: (CRON) INFO (running with inotify support)

# 若未开启
systemctl start crond.service
systemctl enabled crond.service
</code></pre><h2 id="二crontab详细介绍">二、crontab详细介绍</h2>
<h4 id="1-语法">1. 语法</h4>
<pre><code>crontab [ -u user ] file
# 或
crontab [ -u user ] { -l | -r | -e }
</code></pre><p><strong>参数说明</strong></p>
<pre><code>crontab [-u username]　　　　//省略用户表表示操作当前用户的crontab
    -e      (编辑工作表)
    -l      (列出工作表里的命令)
    -r      (删除工作作)
</code></pre><h4 id="2-使用方法">2. 使用方法</h4>
<p>使用命令进入crontab的编辑页面，会自动打开vim编辑计划</p>
<pre><code>[root@localhost ~]# crontab -e

# 以下是自动跳转时需要填入的内容
# 输入数据，基本格式为 :

*　　*　　*　　*　　*　　command12345
</code></pre><p><strong>格式解释</strong></p>
<table>
<thead>
<tr>
<th>参数</th>
<th>含义</th>
<th>范围</th>
</tr>
</thead>
<tbody>
<tr>
<td>第一个 &ldquo;*&rdquo;</td>
<td>一个小时中第几分钟</td>
<td>0-59</td>
</tr>
<tr>
<td>第二个 &ldquo;*&rdquo;</td>
<td>一天中第几个小时</td>
<td>0-23</td>
</tr>
<tr>
<td>第三个 &ldquo;*&rdquo;</td>
<td>一个月中第几天</td>
<td>1-31</td>
</tr>
<tr>
<td>第四个 &ldquo;*&rdquo;</td>
<td>一年中第几个月</td>
<td>1-12</td>
</tr>
<tr>
<td>第五个 &ldquo;*&rdquo;</td>
<td>一周中星期几</td>
<td>0-7（0和7都代表周天）</td>
</tr>
</tbody>
</table>
<p><strong>举例</strong></p>
<table>
<thead>
<tr>
<th>时间</th>
<th>含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>45 22 * * * 命令</td>
<td>每天22点45分执行命令</td>
</tr>
<tr>
<td>0 17 * * 1 命令</td>
<td>每周一12点17分执行命令</td>
</tr>
<tr>
<td>0 5 1,15 * * 命令</td>
<td>每月1号和15号凌晨5点执行命令</td>
</tr>
<tr>
<td>40 4 * * 1-5 命令</td>
<td>每周一到周五凌晨4点40执行命令</td>
</tr>
<tr>
<td>*/10 4 * * * 命令</td>
<td>每天凌晨4点每隔10分钟执行一次命令</td>
</tr>
<tr>
<td>0 0 1,15 * 1 命令</td>
<td>每周一，每月1号和15号的凌晨0点执行命令（注意：星期和月份尽量不要同时出现，容易引发混乱）</td>
</tr>
</tbody>
</table>
<h4 id="3-特殊格式">3. 特殊格式</h4>
<p>crontab包含一些操作符，这些操作符的具体用法如下：</p>
<table>
<thead>
<tr>
<th>时间</th>
<th>含义</th>
</tr>
</thead>
<tbody>
<tr>
<td>*</td>
<td>表示任意时间，默认为 *</td>
</tr>
<tr>
<td>/</td>
<td>代表多久一次，如每过10分钟 */10 4 * * * 命令</td>
</tr>
<tr>
<td>-</td>
<td>连续时间范围，如* * * * 1-6 命令 表示周一到周六</td>
</tr>
<tr>
<td>,</td>
<td>不连续时间，如不联系的日期号，* * 1,2,3,6,9 * * 命令</td>
</tr>
</tbody>
</table>
<h2 id="三具体操作">三、具体操作</h2>
<h4 id="1-导入导出文件">1. 导入导出文件</h4>
<pre><code>#导入
[root@localhost ~]# crontab filename
#导出
[root@localhost ~]# crontab -l &gt;filename1234
</code></pre><p><img src="" alt="导入导出"></p>
<h4 id="2-使用实例">2. 使用实例</h4>
<pre><code># 周一到周五每天下午 5:00 寄一封信给 alex@domain.name
0 17 * * 1-5 mail -s &quot;hi&quot; alex@domain.name &lt; /tmp/maildata

# 每月每天的午夜 0 点 20 分, 2 点 20 分, 4 点 20 分....执行 echo &quot;haha&quot;
20 0-23/2 * * * echo &quot;haha&quot;

# 在上午8点到11点的第3和第15分钟执行
3,15 8-11 * * * myCommand

# 每隔两天的上午8点到11点的第3和第15分钟执行
3,15 8-11 */2  *  * myCommand

# 每周一上午8点到11点的第3和第15分钟执行
3,15 8-11 * * 1 myCommand

# 晚上11点到早上7点之间，每隔一小时重启smb
* 23-7/1 * * * /etc/init.d/smb restart

# /sbin/service httpd restart  意思是每两个小时重启一次apache
0 */2 * * *  

# /sbin/service sshd start  意思是每天7：50开启ssh服务 
50 7 * * * 

# 意思是每天22：50关闭ssh服务 
50 22 * * * /sbin/service sshd stop  

# 每月1号和15号检查/home 磁盘
0 0 1,15 * * fsck /home   

# 每小时的第一分执行 /home/bruce/backup这个文件
1 * * * * /home/bruce/backup   

# 每周一至周五3点钟，在目录/home中，查找文件名为*.xxx的文件，并删除4天前的文件
00 03 * * 1-5 find /home &quot;*.xxx&quot; -mtime +4 -exec rm {} \;

# 每月的1、11、21、31日是的6：30执行一次ls命令
30 6 */10 * * ls  
</code></pre>
                
              </div>

              
                <span class="post-meta">
                  
                    #<a href="https://systemime.github.iotags/linux/">Linux</a>&nbsp;
                  
                    #<a href="https://systemime.github.iotags/crontab/">crontab</a>&nbsp;
                  
                    #<a href="https://systemime.github.iotags/%E5%91%A8%E6%9C%9F/">周期</a>&nbsp;
                  
                </span>
              

            </article>
          
        </div>
        
          <ul class="pager main-pager">
            
            
              <li class="next">
                <a href="https://systemime.github.io/blog/page/2">Older Posts &rarr;</a>
              </li>
            
          </ul>
        
      </div>
    <div align="center" class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
        

<ul class="pagination">
    
    <li class="page-item">
        <a href="https://systemime.github.io/blog/" class="page-link" aria-label="First"><span aria-hidden="true">&laquo;&laquo;</span></a>
    </li>
    
    <li class="page-item disabled">
    <a  class="page-link" aria-label="Previous"><span aria-hidden="true">&laquo;</span></a>
    </li>
    
    
    
    
    
    
    
        
        
    
    
    <li class="page-item active"><a class="page-link" href="https://systemime.github.io/blog/">1</a></li>
    
    
    
    
    
    
        
        
    
    
    <li class="page-item"><a class="page-link" href="https://systemime.github.io/blog/page/2/">2</a></li>
    
    
    
    
    
    
        
        
    
    
    <li class="page-item"><a class="page-link" href="https://systemime.github.io/blog/page/3/">3</a></li>
    
    
    
    
    
    
        
        
    
    
    <li class="page-item disabled"><span aria-hidden="true">&nbsp;&hellip;&nbsp;</span></li>
    
    
    
    
    
    
        
        
    
    
    
    
    
    
    
        
        
    
    
    
    
    
    
    
        
        
    
    
    
    
    
    
    
        
        
    
    
    
    
    
    
    
        
        
    
    
    
    
    
    
    
        
        
    
    
    
    
    
    
    
        
        
    
    
    
    
    
    
    
        
        
    
    
    
    
    
    
    
        
        
    
    
    
    
    
    
    
        
        
    
    
    
    
    
    
    
        
        
    
    
    
    
    
    
    
        
        
    
    
    
    
    
    
    
        
        
    
    
    
    
    
    
    
        
        
    
    
    <li class="page-item"><a class="page-link" href="https://systemime.github.io/blog/page/18/">18</a></li>
    
    
    <li class="page-item">
    <a href="https://systemime.github.io/blog/page/2/" class="page-link" aria-label="Next"><span aria-hidden="true">&raquo;</span></a>
    </li>
    
    <li class="page-item">
        <a href="https://systemime.github.io/blog/page/18/" class="page-link" aria-label="Last"><span aria-hidden="true">&raquo;&raquo;</span></a>
    </li>
    
</ul>


        
        
        
        
        
      </div>
    </div>
  </div>

    <div class="rocket"><img src="https://systemime.github.io/img/rocket_up.png" alt="" width="100" height="100"></div>
<script>
    $(function () {
      $(window).scroll(function () {
        
        if ($(window).scrollTop() >= 1000) {
          $('.rocket').stop().fadeIn(1000);
        }else {
          $('.rocket').stop().fadeOut(1000);
        }
      })
      
      $('.rocket').click(function () {
        $('html,body').stop().animate({scrollTop:0},400);
       
      })
    })

</script>

    
    <div id="landlord">
        <div class="message" style="opacity:0"></div>
        <canvas id="live2d" width="280" height="250" class="live2d"></canvas>
        <div class="hide-button">隐藏</div>
    </div>
    
    <footer id="copyright">
  <div class="container">
    <div class="row">
      <div class="col-lg-8 col-lg-offset-2 col-md-10 col-md-offset-1">
        <ul class="list-inline text-center footer-links">
          
          
        </ul>
        <p class="credits copyright text-muted">
        &copy;2017-2018
          
          &nbsp;&bull;&nbsp;
          September 20,2019
          updated
          
            &nbsp;&bull;&nbsp;
            <a href="https://systemime.github.io">Home</a>
          
        </p>

        <p class="credits theme-by text-muted">
        <a href="https://servicemesher.github.io" target="_blank">ServiceMesher</a>&nbsp;&bull;&nbsp;<a href="https://github.com/yangchuansheng/k8s-knowledge" target="_blank">Kubernetes 知识图谱</a>
        <br />
        <span id="busuanzi_container_site_pv">
            本站已被访问 <span id="busuanzi_value_site_pv"></span> 次啦
        </span>
        <span id="busuanzi_container_site_uv">
            &ensp;|&ensp;&thinsp;您是第 <span id="busuanzi_value_site_uv"></span> 位到访的小伙伴喔
        </span>
        </p>
        
        <p class="credits theme-by text-muted">
          <a href="http://gohugo.io">Hugo v0.67.0</a> powered &nbsp;&bull;&nbsp; Theme by <a href="http://deanattali.com/beautiful-jekyll/">Beautiful Jekyll</a> adapted to <a href="https://github.com/halogenica/beautifulhugo">Beautiful Hugo</a>
          
          <center><section class="credits theme-by text-muted">
    <span class="footer__copyright">
    <div>
    <span id="span_dt_dt"> </span>
    <script language="javascript">
      function show_date_time(){
        window.setTimeout("show_date_time()", 1000);
        BirthDay=new Date("7/8/2017 10:56:12");
        today=new Date();
        timeold=(today.getTime()-BirthDay.getTime());
        sectimeold=timeold/1000
        secondsold=Math.floor(sectimeold);
        msPerDay=24*60*60*1000
        e_daysold=timeold/msPerDay
        daysold=Math.floor(e_daysold);
        e_hrsold=(e_daysold-daysold)*24;
        hrsold=Math.floor(e_hrsold);
        e_minsold=(e_hrsold-hrsold)*60;
        minsold=Math.floor((e_hrsold-hrsold)*60);
        seconds=Math.floor((e_minsold-minsold)*60);
        span_dt_dt.innerHTML="本博客已经开心运行 "+daysold+" 天 "+hrsold+" 小时 "+minsold+" 分 "+seconds+" 秒";
      }
      show_date_time();
    </script>
    </div>
</script>
</section>
</center>
        </p>
      </div>
    </div>
  </div>
</footer>


<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/bootstrap.min.js"></script>
<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/photoswipe-ui-default.min.js"></script>
<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/photoswipe.min.js"></script>
<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/auto-render.min.js"></script>
<script src="https://systemime.github.io/js/main.js"></script>
<script src="https://systemime.github.io/js/clipboard.min.js"></script>
<script src="https://systemime.github.io/js/prism.js?t=123"></script>
<script src="https://systemime.github.io/js/highlight.min.js"></script>
<script src="https://res.cloudinary.com/jimmysong/raw/upload/rootsongjc-hugo/katex.min.js"></script>
<script src="https://systemime.github.io/js/reward.js"></script>
<script src="https://systemime.github.io/js/canvas_ribbon.js"></script>
<script> renderMathInElement(document.body); </script>

<script src="https://systemime.github.io/js/baguetteBox.js"></script>
<script> baguetteBox.run('.gallery');</script>






<script async defer src="https://buttons.github.io/buttons.js"></script>


<script src="https://polyfill.io/v2/polyfill.min.js?features=IntersectionObserver"></script>
<script type="text/javascript" src="https://systemime.github.io/js/quicklink.umd.js"></script>
<script>
window.addEventListener('load', () =>{
   quicklink();
});
</script>



<script type="text/javascript">
 
var a_idx = 0;
jQuery(document).ready(function($) {
    $("body").click(function(e) {
        var a = new Array("Docker", "Kubernetes", "Prometheus", "Envoy", "Istio", "Service Mesh", "Cloud Native");
        var $i = $("<span />").text(a[a_idx]);
        a_idx = (a_idx + 1) % a.length;
        var x = e.pageX,
        y = e.pageY;
        function randomColor() {
          var flakeColor = new Array("#FFDA65", "#00BFFF", "#BA55D3", "#FFA07A", "#87CEEB", "#FFB6C1");
          var snowColor = flakeColor[Math.floor(flakeColor.length * Math.random())];
          return snowColor;
        }
        $i.css({
            "z-index": 999999999999999999999999999999999999999999999999999999999999999999999,
            "top": y - 20,
            "left": x,
            "position": "absolute",
            "font-weight": "bold",
            "color": randomColor()
        });
        $("body").append($i);
        $i.animate({
            "top": y - 180,
            "opacity": 0
        },
        1500,
        function() {
            $i.remove();
        });
    });
});
</script>


<script type="text/javascript" src="https://systemime.github.io/js/lightbox.js"></script>











<script src="https://cdn.plyr.io/3.4.7/plyr.js"></script>
<script>const player = new Plyr('#player');</script>


<script async defer src="https://buttons.github.io/buttons.js"></script>


  </body>
</html>

